CKEDITOR.plugins.add( 'drupalhelp',
    {
        init : function( editor )
        {
            //console.log(editor.lang.stylesCombo);
            // Add the link and unlink buttons.
            editor.addCommand( 'drupalhelp', new CKEDITOR.dialogCommand( 'drupalhelp' ) );
            editor.ui.addButton( 'DrupalHelp',
            {
                label :  'Help' ,
                icon : this.path + 'images/drupalhelp.gif',
                command : 'drupalhelp'
            } );
            CKEDITOR.dialog.add( 'drupalhelp', this.path + 'dialogs/help.js' );

            var config = editor.config;

            editor.ui.addRichCombo( 'varSelect',
            {
                label : "Insert variable",
                title : 'variable',
                multiSelect : false,

                panel :
                {
                    css : [ CKEDITOR.getUrl( editor.skinPath + 'editor.css' ) ].concat( config.contentsCss )
                },

                init : function()
                {
                    var variable;
                    var variableOptions = this.getVariables();
                        
                    this.startGroup( 'variables' );

                    for (element in variableOptions)
                    {
                        this.add( element, variableOptions[element], variableOptions[element]);
                    }

                    // Default value on first click
                   // this.setValue('asd', "asd");
                },
                onClick : function( value )
                {
                    var body = editor.document.getBody().$;
                //  alert('asd22');
                /*
                    body.style.MozTransformOrigin = "top left";
                    body.style.MozTransform = "scale(" + (value/100)  + ")";

                    body.style.WebkitTransformOrigin = "top left";
                    body.style.WebkitTransform = "scale(" + (value/100)  + ")";

                    body.style.OTransformOrigin = "top left";
                    body.style.OTransform = "scale(" + (value/100)  + ")";

                    body.style.TransformOrigin = "top left";
                    body.style.Transform = "scale(" + (value/100)  + ")";
                    // IE
                    body.style.zoom = value/100;
                    */
                },
                getVariables: function(){
                    // var test = $('#testID').html(); alert(test);
                    var result = new Array( 'asd','zxc');
                    
                    var variable = {
                        lastname: "Иванов",
                        firstname: "Василий",
                        middlename: "Петрович"
                    }
                   
                    return variable;
                }
            });

          
        }
    } );